package views;
import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import presenters.PaymentInfoPresenter;


public class PaymentInfoPanel extends JPanel {
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private PaymentInfoPresenter myPresenter;

	/**
	 * Create the panel.
	 */
	public PaymentInfoPanel() {
		setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		add(panel, BorderLayout.CENTER);
		
		Box verticalBox = Box.createVerticalBox();
		panel.add(verticalBox);
		
		JLabel lblNewLabel = new JLabel("Name On The Card:");
		verticalBox.add(lblNewLabel);
		
		textField = new JTextField();
		verticalBox.add(textField);
		textField.setColumns(10);
		
		Component verticalStrut_1 = Box.createVerticalStrut(20);
		verticalBox.add(verticalStrut_1);
		
		JLabel lblCardNumber = new JLabel("Card Number:");
		verticalBox.add(lblCardNumber);
		
		textField_1 = new JTextField();
		verticalBox.add(textField_1);
		textField_1.setColumns(10);
		
		Component verticalStrut_3 = Box.createVerticalStrut(20);
		verticalBox.add(verticalStrut_3);
		
		JLabel lblNewLabel_1 = new JLabel("CVV:");
		verticalBox.add(lblNewLabel_1);
		
		textField_2 = new JTextField();
		verticalBox.add(textField_2);
		textField_2.setColumns(10);
		
		Component verticalStrut_2 = Box.createVerticalStrut(20);
		verticalBox.add(verticalStrut_2);
		
		JLabel lblNewLabel_2 = new JLabel("Expiry Date:");
		verticalBox.add(lblNewLabel_2);
		
		textField_3 = new JTextField();
		verticalBox.add(textField_3);
		textField_3.setColumns(10);
		
		Component verticalStrut_4 = Box.createVerticalStrut(20);
		verticalBox.add(verticalStrut_4);
		
		JLabel lblNewLabel_3 = new JLabel("Billing Address:");
		verticalBox.add(lblNewLabel_3);
		
		textField_4 = new JTextField();
		verticalBox.add(textField_4);
		textField_4.setColumns(10);
		
		Component verticalStrut_5 = Box.createVerticalStrut(20);
		verticalBox.add(verticalStrut_5);
		
		JLabel lblPaymentInformation = new JLabel("Payment Information:");
		add(lblPaymentInformation, BorderLayout.NORTH);

		myPresenter = new PaymentInfoPresenter(this);
	}
	
	public PaymentInfoPresenter getMyPresenter() {
		return myPresenter;
	}

	public String process() {
		String name = textField.getText();
		String card_no = textField_1.getText();
		String cvv = textField_2.getText();
		String exper = textField_3.getText();
		String address = textField_4.getText();
		
		myPresenter.updatePayment(name, card_no, cvv, exper, address);
		return card_no;
	}
	
	public void setFields(String name, String cardNo, String cvv, String expir, String bill) {
		textField.setText(name);
		textField_1.setText(cardNo);
		textField_2.setText(cvv);
		textField_3.setText(expir);
		textField_4.setText(bill);
	}

}
